<?php
/*------------------------------------------------------------------------
# company - company management
# @author    pipapai.com
-------------------------------------------------------------------------*/

defined('_JEXEC') or die;
// disable core styles to avoid bs conflict
OC_Util::$core_styles = array();

if(isDevMode()) {
   OCP\Util::addStyle('company', 'company');
   OCP\Util::addScript('company', 'settings');
} else {
   OCP\Util::addStyle('static', 'company');
   OCP\Util::addScript('static', 'apps/company.settings.min');
}

OCP\App::setActiveNavigationEntry('company_settings');

$lang = PFactory::getLanguage();
$lang->load("com_jobs", JPATH_SITE, "zh-CN");

$user = $_['user'];
UserPrivacy::getUserPrivacySettings($user, 'com_company');
?>
<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('company/js', 'company.php'));?>"></script>

<div class="hr_inner_navigate clearfix">
   <ul class="clearfix">
      <?php PCompanyHelper::showNavigationMenu($_['masteruser'], 'basicinfo');?>
   </ul>
</div>

<div class="hr_company_set">
   <form id="settingbasicform" action="<?php echo OC_Helper::linkToRoute("company_savesettings"); ?>" method="post" name="basicform">

      <div class="basicinfoform">
         <div class="form-horizontal">

            <div class="control-group">
               <label class="control-label key">公司名称:</label>
               <div class="controls">
                  <?php if($user->validated == EMPLOYER_VALIDATED): ?>
                  <span class="only_text" title="已通过验证，不可自行更改。如需变更，请联系客服。" data-placement="right"><?=trim($user->comp_name)?></span>
                  <?php else: ?>
                  <input type="text" class="input-xlarge required" name="comp_name" id="comp_name" minlenght="2" title="公司名字必须和营业执照一致。验证一旦通过，不可更改" data-placement="right" value="<?=trim($user->comp_name)?>" />
                  <?php endif; ?>
               </div>
            </div>
            <div class="control-group">
               <label class="control-label key">企业邮箱:</label>
               <div class="controls">
                  <span class="only_text" title="企业邮箱不可自行更改。如需变更，请联系客服。" data-placement="right">
                     <?=$user->email?><span class='small'>&nbsp;&nbsp;(邮箱不可更改)</span>
                  </span>
               </div>
            </div>
            <?php if(0): ?>
            <div class="control-group">
               <label class="control-label key">专属域名:</label>
               <div class="controls">
                  <?php if(!$_['isset_subdomain']): ?>
                  http://
                  <input type="text" class="input-small" name="sub_domain" id="sub_domain" minlenght="6" title="专属域名长度5～64位。设置过后，不可更改。" data-placement="right" value="" />.<?php echo PUtil::serverDomain(); ?>
                  <?php else: ?>
                  <span class="only_text" title="您已设置过专属域名，不可更改。" data-placement="right">
                     <?php echo "http://".$user->sub_domain.".".PUtil::serverDomain();?><span class='small'>&nbsp;&nbsp;(专属域名不可更改)</span>
                  </span>
                  <?php endif; ?>
               </div>
            </div>
            <?php endif; ?>
            <div class="control-group">
               <label class="control-label key"><span class="required">*</span>所在地区:</label>
               <div class="controls">
                  <?php echo JobHelper::getSelectProvince("id_state", $user->id_state, 0, "class='slt_mid'"); ?>
                  <select id="id_city" name="id_city" defvalue="<?=$user->id_city?>"></select>
                  <input type="hidden" id="state" name="state" value="<?=$user->state?>" />
                  <input type="hidden" id="city" name="city" value="<?=$user->city?>" />
                  <label for="id_city" class="error" style="display:none">请选择地区</label>
               </div>
            </div>
            <div class="control-group">
               <label class="control-label key"><span class="required">*</span>公司性质:</label>
               <div class="controls">
                  <?php echo JobHelper::getSelectCompType('id_comp_type', $user->id_comp_type, 0, "class='slt_mid'");?>
               </div>
            </div>
            <div class="control-group">
               <label class="control-label key"><span class="required">*</span>公司行业:</label>
                <div class="controls">
                   <input type="text" name="industry_name" id="industry_name" style="width:270px;" value="<?php echo JText::_($user->industry);?>"/><a id="selectindustry" class="ppp_whitebtn whitebtn" href="javascript:;" style="margin-left:5px;">选择行业</a>
                   <input type="hidden" name="id_industry" id="id_industry" value="<?php echo $user->id_industry;?>" />
                </div>
            </div>
            <div class="control-group">
               <label class="control-label key"><span class="required">*</span>公司规模:</label>
               <div class="controls">
                  <?php echo JobHelper::getSelectCompSizeType('id_size_type', $user->id_size_type, 0, "class='slt_mid'"); ?>
               </div>
            </div>
            <div class="control-group">
               <label class="control-label key"><span class="required">*</span>联系人:</label>
               <div class="controls">
                  <input type="text" class="input-xlarge" name="contact_name" id="contact_name" value="<?=$user->contact_name?>"/>
                  <div id="contact_name_privacy" class="ppp_whitebtn c_privacysetting dropdown" data-privacyinput='contactnameprivacy'>
                     <?php 
                        $privacyvalue = USER_PRIVACY_PRIVATE; 
                        $privacy = UserPrivacy::getUserPrivacyFieldSetting($user, 'contactname');
                        if($privacy) 
                           $privacyvalue = $privacy->privacy; 

                        $privacytext = ($privacyvalue == USER_PRIVACY_PRIVATE)?'不公开':'公开';
                     ?>
                     <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" data-target="#"><b><?=$privacytext?></b> <i></i></a>
                     <div class="dropdown-menu">
                        <a href="javascript:;" data-privacy="<?=USER_PRIVACY_PUBLIC?>">公开</a>
                        <a href="javascript:;" data-privacy="<?=USER_PRIVACY_PRIVATE?>">不公开</a>
                     </div>
                  </div>
                  <input type="hidden" name="contactnameprivacy" id="contactnameprivacy" value="<?=$privacyvalue?>"/>
                  <input type="hidden" name="contactnamefieldid" id="contactnamefieldid" value="<?=($privacy ? $privacy->fieldid : 0) ?>"/>
               </div>
            </div>
            <div class="control-group">
               <label class="control-label key"><span class="required">*</span>联系电话:</label>
               <div class="controls">
                  <input type="text" class="input-xlarge" name="phone" id="phone" value="<?=$user->phone?>"/>
                  <div id="phone_privacy" class="ppp_whitebtn c_privacysetting dropdown" data-privacyinput="phoneprivacy">
                     <?php
                        $phoneprivacyvalue = USER_PRIVACY_PRIVATE;
                        $phoneprivacy = UserPrivacy::getUserPrivacyFieldSetting($user, 'telephone');
                        if($phoneprivacy)
                           $phoneprivacyvalue = $phoneprivacy->privacy;

                        $phoneprivacytext = ($phoneprivacyvalue == USER_PRIVACY_PRIVATE)?'不公开':'公开';
                     ?>
                     <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" data-target="#"><b><?=$phoneprivacytext?></b> <i></i></a>
                     <div class="dropdown-menu">
                        <a href="javascript:;" data-privacy="<?=USER_PRIVACY_PUBLIC?>">公开</a>
                        <a href="javascript:;" data-privacy="<?=USER_PRIVACY_PRIVATE?>">不公开</a>
                     </div>
                  </div>
                  <input type="hidden" name="phoneprivacy" id="phoneprivacy" value="<?=$phoneprivacyvalue?>"/>
                  <input type="hidden" name="phonefieldid" id="phonefieldid" value="<?=($phoneprivacy ? $phoneprivacy->fieldid : 0)  ?>"/>
               </div>
            </div>
            <div class="control-group">
               <label class="control-label key"><span class="required">*</span>公司地址:</label>
               <div class="controls">
                  <input type="text" class="input-xlarge"  name="address" id="address" value="<?=$user->address?>"/>
               </div>
            </div>
            <div class="control-group">
               <label class="control-label key">公司网址:</label>
               <div class="controls">
                  <input type="text" class="input-xlarge url"  name="website" id="website" value="<?=$user->website?>"/>
               </div>
            </div>
            <div class="login_action clearfix">
               <div class="controls">
                  <button class="btn btn-info pull-left">保 存</button>
                  <label class="pull-left" style="width:auto; padding-top:6px; margin-left:10px;">
                    <span class="error server"></span>
                  </label>
               </div>
            </div>
         </div>
      </div>
      <input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
   </form>
</div>

<!--  公司行业 dialog  -->         
<div class="modal hide fade resume_dialogposition selectwork_dialog" style="position:absolute;" id="selectindustry_dialog">
   <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      <h3>请选择行业</h3>
   </div>
   <input type="hidden" id="select_work_id">
   <input type="hidden" id="select_work_text">
   <div class="modal-body">
   </div>
   <div class="modal-footer nobgcolor">
      <a href="javascript:;" class="btn removeselected">清空选择</a>
   </div>
</div>

